#include <ringbuffer.h>
#include <stdio.h>
#include "Queue.h"

typedef struct rb_example {
	int a;
	int b;
} rb_example_t; 

int ringbuffer_example(void) {
	rb_example_t data = {
		.a = 1,
		.b = 2,
	};

	struct rt_ringbuffer * rb = rt_ringbuffer_create(sizeof(rb_example_t) * 2);
	RT_ASSERT(rb != RT_NULL);

	printf("Put data to   ringbuffer, a: %d b: %d size: %d\n", data.a, data.b, sizeof(data));
	rt_ringbuffer_put(rb, (rt_uint8_t*)&data, sizeof(data));

	rb_example_t recv_data;
	rt_size_t recv = rt_ringbuffer_get(rb, (rt_uint8_t*)&recv_data, sizeof(recv_data));
	RT_ASSERT(recv == sizeof(recv_data));
	printf("Get data from ringbuffer, a: %d b: %d size: %d\n", recv_data.a, recv_data.b, sizeof(recv_data));

	return 0;
}
